// src/store/index.js
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    photoLinks: ["https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",]
  },
  mutations: {
    setPhotoLinks(state, links) {
      state.photoLinks = links;
    },
    addPhotoLink(state, link) {
      state.photoLinks.push(link);
    }
  },
  actions: {
    fetchPhotoLinks({ commit }) {
      // 模拟从 API 获取照片链接
      const links = [
        "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
      ];
      commit('setPhotoLinks', links);
    },
    addNewPhotoLink({ commit }, link) {
      commit('addPhotoLink', link);
    }
  },
  getters: {
    getPhotoLinks: state => state.photoLinks
  }
});